package com.denlaku.longan.audit;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author tianx
 */
class AuditVariablesPack {
    private boolean initialized;

    private final Map<String, Object> variables = new LinkedHashMap<>();

    void init() {
        initialized = true;
        variables.clear();
    }

    void clear() {
        this.initialized = false;
        variables.clear();
    }

    Map<String, Object> getVariables() {
        return Collections.unmodifiableMap(variables);
    }

    void setVariable(String name, Object value) {
        if (initialized) {
            this.variables.put(name, value);
        }
    }
}
